package com.wang.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.wang.pojo.TbScheme;
import com.wang.pojo.TbSicknessScheme;
import com.wang.service.TbSchemeService;
import com.wang.mapper.TbSchemeMapper;
import com.wang.service.TbSicknessSchemeService;
import com.wang.utills.JwtUtils;
import com.wang.utills.R;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 *方案
 */
@Service
public class TbSchemeServiceImpl extends ServiceImpl<TbSchemeMapper, TbScheme>
    implements TbSchemeService{

    @Resource
    private  TbSchemeMapper tbSchemeMapper;

    @Resource
    private TbSicknessSchemeService tbSicknessSchemeService;


    @Override
    public R schemelist() {
        List<TbScheme> list=tbSchemeMapper.selectList(new QueryWrapper<>());
        return new R(200, "true", list);

    }

    @Override
    public R addnewone(TbScheme tbScheme) {
        //方案的添加
        this.tbSchemeMapper.insert(tbScheme);
        return new R(200, "添加", null);
    }

    @Override
    public TbScheme getschemebysid(Integer fid) {
        TbScheme tbScheme = this.tbSchemeMapper.selectById(fid);
        return tbScheme;
    }



    @Override
    public R addnewonebysid(TbScheme tbScheme, Integer sid) {
        //中间表进行添加
        this.addnewone(tbScheme);
        TbSicknessScheme tbSicknessScheme = new TbSicknessScheme();
        tbSicknessScheme.setSid(sid);
        tbSicknessScheme.setFid(tbScheme.getSid());
        this.tbSicknessSchemeService.addnewsicksche(tbSicknessScheme);
        return null;
    }


}




